import {message} from 'antd';
import {formatMessage} from './intl';

export const newOrUpdateOrderValidator = (data, dealerResourceLists) => {
    const requiredFields = [];
    if(!data || !data.brandId)
        requiredFields.push(
            formatMessage({
                id: 'validator.brandId',
                defaultMessage: '品牌'
            })
        );
    if(requiredFields.length > 0) {
        message.warning(`${requiredFields.join('，')}${formatMessage({
            id: 'validator.requied',
            defaultMessage: '必填'
        })}`);
        return false;
    }
    if(!dealerResourceLists || (dealerResourceLists && dealerResourceLists.length === 0)) {
        message.warning(formatMessage({
            id: 'validator.message.detailQuantity',
            defaultMessage: '清单不能为空！'
        }));
        return false;
    }
    return true;
};
